/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.springtree.spectrum.visa.mvc.model;

import co.springtree.spectrum.visa.persistence.PersistenceFacade;
import co.springtree.spectrum.visa.persistence.entities.CommandDTO;
import java.sql.SQLException;
import java.util.Collection;
import org.apache.log4j.Logger;
/**
 *
 * @author Ricardo
 */
public class CommandModel {
    private static Logger logger = Logger.getLogger("CommandModel");
    private PersistenceFacade persistence = PersistenceFacade.getInstance();
    private CommandDTO command = new CommandDTO();
    private Collection<CommandDTO> commandColl;
    
    public void init(){
        this.updateCommandList();
    }
    public void createCommand(){
        try {
            this.persistence.getCommandDAO().insert(command);
        } catch (SQLException ex) {
            logger.error(ex);
        }
    }
    
    public void updateCommandList(){
        try {
            this.commandColl = this.persistence.getCommandDAO().selectAll();
        } catch (SQLException ex) {
            logger.error(ex);
        }
    }

    public CommandDTO getCommand() {
        return command;
    }

    public void setCommand(CommandDTO command) {
        this.command = command;
    }

    public Collection<CommandDTO> getCommandColl() {
        return commandColl;
    }
    
}